<?php

/**
 * This is the model class for table "sh_quote".
 *
 * The followings are the available columns in table 'sh_quote':
 * @property string $quote_id
 * @property string $created_at
 * @property string $updated_at
 * @property integer $is_active
 * @property string $items_count
 * @property string $items_qty
 * @property string $grand_total
 * @property string $customer_id
 * @property string $subtotal
 */
class Quote extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Quote the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'sh_quote';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('is_active', 'numerical', 'integerOnly'=>true),
			array('items_count, customer_id', 'length', 'max'=>10),
			array('items_qty, grand_total, subtotal', 'length', 'max'=>16),
			array('created_at, updated_at', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('quote_id, created_at, updated_at, is_active, items_count, items_qty, grand_total, customer_id, subtotal', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'quote_id' => 'Quote',
			'created_at' => 'Created At',
			'updated_at' => 'Updated At',
			'is_active' => 'Is Active',
			'items_count' => 'Items Count',
			'items_qty' => 'Items Qty',
			'grand_total' => 'Grand Total',
			'customer_id' => 'Customer',
			'subtotal' => 'Subtotal',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('quote_id',$this->quote_id,true);
		$criteria->compare('created_at',$this->created_at,true);
		$criteria->compare('updated_at',$this->updated_at,true);
		$criteria->compare('is_active',$this->is_active);
		$criteria->compare('items_count',$this->items_count,true);
		$criteria->compare('items_qty',$this->items_qty,true);
		$criteria->compare('grand_total',$this->grand_total,true);
		$criteria->compare('customer_id',$this->customer_id,true);
		$criteria->compare('subtotal',$this->subtotal,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}